Draft
Conversation
alexandruradovici
requested changes
Apr 3, 2023
| libtock_platform = { path = "../../platform" } | ||
|
|
||
| [dev-dependencies] | ||
| libtock_unittest = { path = "../../unittest" } No newline at end of file |
| /// Initiate a humidity measurement. | ||
| /// | ||
| /// This function is used both for synchronous and asynchronous readings | ||
| pub fn read_humidity() -> Result<(), ErrorCode> { |
There was a problem hiding this comment.
Suggested change
| pub fn read_humidity() -> Result<(), ErrorCode> { | |
| pub fn read() -> Result<(), ErrorCode> { |
| } | ||
|
|
||
| /// Register an events listener | ||
| pub fn register_listener<'share, F: Fn(i32)>( |
There was a problem hiding this comment.
I think this should be Fn(u32).
| }; | ||
| } | ||
|
|
||
| pub mod humidity { |
Comment on lines
+12
to
+14
| // The `upcall_on_command` field is set to Some(value) if an upcall(with value as its argument) should be called when read command is received, | ||
| // or None otherwise. It was needed for testing `read_sync` library function which simulates a synchronous humidity read, | ||
| // because it was impossible to schedule an upcall during the `synchronous` read in other ways. |
There was a problem hiding this comment.
Move this as a comment next to the field.
| pub use buttons::Buttons; | ||
| pub use console::Console; | ||
| pub use gpio::{Gpio, GpioMode, InterruptEdge, PullMode}; | ||
| pub use humidity::Humidity; |
alexandruradovici
requested changes
Apr 24, 2023
Comment on lines
+18
to
+24
| match Humidity::exists() { | ||
| Ok(()) => writeln!(Console::writer(), "humidity driver available").unwrap(), | ||
| Err(_) => { | ||
| writeln!(Console::writer(), "humidity driver unavailable").unwrap(); | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
Suggested change
| match Humidity::exists() { | |
| Ok(()) => writeln!(Console::writer(), "humidity driver available").unwrap(), | |
| Err(_) => { | |
| writeln!(Console::writer(), "humidity driver unavailable").unwrap(); | |
| return; | |
| } | |
| } | |
| if Humidity::exists().is_err() { | |
| writeln!(Console::writer(), "humidity driver unavailable").unwrap(); | |
| return; | |
| } |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Heavily inspired from the work done here.
I observed that the C implementation is similar to the one for temperature and this conversion should be compatible.
One thing to note is that in the C files the humidity is represented as an
unsigned int, whereas in my conversion I left it asi32.